<template>
  <div id="right2"></div>
</template>
<script>
import * as echarts from "echarts";
import { http } from "@/api/request";
export default {
  data() {
    return {};
  },
  methods: {},
  components: {},
  computed: {},
  watch: {},
  created() {},
  async mounted() {
    // 
    var {globalDailyHistory}=await http()
    var date=[],dead=[],heal=[]
    globalDailyHistory.forEach(item=>{
      date.push(item.date)
      dead.push(item.all.dead)
      heal.push(item.all.heal)
    })
    var chartDom = document.getElementById("right2");
    var myChart = echarts.init(chartDom);
    window.onresize = function() {
      myChart.resize()
    }
    var option = {
      title: {
        text: "世界每周新增治愈和死亡人数",
        x: "center",
        y: "2%",
        textStyle: {
          color: "#fff",
          fontSize: "16",
        },
      },
      tooltip: {
        trigger: "axis",
        axisPointer: {
          type: "cross",
          label: {
            backgroundColor: "#6a7985",
          },
        },
      },
      legend: {
        data: ["Email", "Union Ads", "Video Ads", "Direct", "Search Engine"],
      },
      toolbox: {
        feature: {
          saveAsImage: {},
        },
      },
      grid: {
        left: "3%",
        right: "4%",
        bottom: "3%",
        containLabel: true,
      },
      xAxis: [
        {
          type: "category",
          boundaryGap: false,
          data: date,
        },
      ],
      yAxis: [
        {
          type: "value",
        },
      ],
      series: [
        {
          name: "Email",
          type: "line",
          stack: "Total",
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: dead,
        },
        {
          name: "Union Ads",
          type: "line",
          stack: "Total",
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: heal,
        },
        
      ],
    };
    option && myChart.setOption(option);
  },
};
</script>
<style lang="scss" scoped>
#right2 {
  width: 100%;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
}
</style>
